-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix warnings for signedness #312
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This goes in wrong direction. Unsigned types should be avoided. They are only good for bitfields and bit manipulation.
src/eei.cpp
Outdated
@@ -370,20 +370,20 @@ inline int64_t maxCallGas(int64_t gas) { | |||
|
|||
takeInterfaceGas(GasSchedule::base); | |||
|
|||
return Literal(static_cast<uint32_t>(m_code.size())); | |||
return Literal(uint32_t(m_code.size())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not hide a cast.
I don't get it, why? |
|
Still, why? |
I had to look it up. Most of the arguments are listed here (read all section): https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#arithmetic. I should add that you can detect signed overflow with Undefined Behavior Sanitizer (with the newest version you can also detect unsigned overflows, but because they are valid in C++, you can get false positives). Together with fuzz testing this gives incredible results. |
Codecov Report
@@ Coverage Diff @@
## master #312 +/- ##
=========================================
Coverage ? 67.55%
=========================================
Files ? 5
Lines ? 860
Branches ? 122
=========================================
Hits ? 581
Misses ? 251
Partials ? 28 |
As discussed the specification isn't clear what the types of these are, but implicitly it feels they are defined as unsigned in the EEI. Added an issue to review that: ewasm/design#132 Merging this change as it doesn't changes semantics. |
Part of #311.